public class Solution {
    public static void main(String[] args) {
        /**
         * 二叉搜索树实现*/
        BinarySearchTree tree = new BinarySearchTree();

        // 测试插入
        tree.insert(7);
        tree.insert(6);
        tree.insert(5);
        tree.insert(8);
        tree.insert(9);
        tree.insert(3);

        // 测试搜索
        System.out.println(tree.search(7));
        System.out.println(tree.search(3));
        System.out.println(tree.search(-1));
        System.out.println(tree.search(10));
        System.out.println("---------------");

        // 测试打印
        System.out.println("原树：");
        tree.displayByInfixOrder(tree.root);
        System.out.println();

        // 测试删除
        System.out.println("删除根节点7");
        tree.remove(7);
        tree.displayByInfixOrder(tree.root);
        System.out.println();

        System.out.println("删除不存在节点99");
        tree.remove(99);
        tree.displayByInfixOrder(tree.root);
        System.out.println();

        System.out.println("删除其余节点5");
        tree.remove(5);
        tree.displayByInfixOrder(tree.root);
        System.out.println();
    }



}
